<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>盛最多水的容器</title>
</head>
<body>
  <script>
    function fn(height) {
      //两根主子间的最大面积
      let max = 0;
      //使用双指针求面积
      for (let i = 0, j = height.length - 1; i < j;) {
        //求两根柱子之间高度低的哪一个
        let minHeight = height[i] < height[j] ? height[i++] : height[j--]
        //两个柱子之间的宽度
        let leng = j - i + 1;
        //求面积
        let area = leng * minHeight;
        //取最大值
        max = Math.max(max, area)
      }
      return max
    }
    console.log(fn())
  </script>
</body>
</html>